#pragma once

namespace xxhhdzl
{
	template<class T>
	class auto_ptr
	{
	public:
		auto_ptr(T* sp = nullptr)
			:ptr(sp)
		{
		}

		auto_ptr(auto_ptr<T>& sp)
		{
			ptr = sp.ptr;
			sp.ptr = nullptr;
		}

		auto_ptr<T>& operator=(auto_ptr<T>& sp)
		{
			if (ptr != sp.ptr)
			{
				delete ptr;
				ptr = sp.ptr;
				sp.ptr = nullptr;
			}
			return *this;
		}

		T& operator*()
		{
			return *ptr;
		}

		T* operator->()
		{
			return ptr;
		}

		~auto_ptr()
		{
			delete ptr;
		}


		T* ptr;
	};
}
